package com.testxmlparse;

import java.io.File;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.junit.Test;

import com.google.common.collect.Lists;

import cn.com.zte.ant.model.AntModelLoader;
import cn.com.zte.ant.model.AntModelObjectPartner;
import cn.com.zte.ant.model.ModelRalationSearcher;
import cn.com.zte.ant.task.doc.nj.excel.tools.NsqlExcelProcessor;
import cn.com.zte.ngbc.frw.model.ModelFileAware;
import cn.com.zte.ngbc.frw.model.generator.ModelJavaGenerator;
import cn.com.zte.ngbc.frw.model.generator.ModelJavaGenerator.JavaClassModel;
import cn.com.zte.ngbc.frw.model.sql.SqlGroup;
import org.apache.commons.io.FileUtils;


public class Impljava_windows extends ModelRalationSearcher {

	@Test	
	public  void Tesa() throws Exception {	    
	    Set<File> ret11 = new HashSet();
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/datatype/BaseType.u_schema.xml"));
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/datatype/BaseEnumType.e_schema.xml"));
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/dict/AcDict.d_schema.xml"));
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/dict/ApDict.d_schema.xml"));
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/dict/AtDict.d_schema.xml"));
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/dict/CdDict.d_schema.xml"));
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/dict/CfDict.d_schema.xml"));
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/dict/CmDict.d_schema.xml"));
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/dict/LtDict.d_schema.xml"));
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/dict/StDict.d_schema.xml"));
	    ret11.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/dict/TaDict.d_schema.xml"));
	    //ret11.add(new File("C:\\Users\\XiaoMotian\\Desktop\\depend\\TlNbXxgl.serviceType.xml"));
	   
	    Set<File> reta = new HashSet();

	 //   
	    File files=new File("E:\\workspace_dev\\dpsrc");
		Collection<File> filesCollection = FileUtils.listFiles(files, new String[] { "nsql.xml"}, true);
		if (filesCollection.size() >0 && filesCollection !=null) {
			for (File file : filesCollection) {
				String xmlFilePath = file.getAbsolutePath();
				System.out.println(xmlFilePath);
				 reta.add(file);
			}
		}
	//    reta.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/CaCdkmtbAPI.nsql.xml"));
//	                       C:/Users/zte/git/nosqlproject/src/main/resources/CaCdkmtbAPI.nsql.xml
	  //  reta.add(new File("C:/Users/zte/git/nosqlproject/src/main/resources/FmBusiScxc.nsql.xml"));
	    
	    
	    
	    AntModelLoader m = new AntModelLoader(reta,ret11);
	    AntModelObjectPartner.setModelLoader(m);
	    List<SqlGroup> models = Lists.newArrayList();
	    for (Object model1 : m.getSourceModels())
	      {
	        ModelFileAware modelFile = (ModelFileAware)model1;
	        System.out.println(modelFile.getId());
	
	        models.add((SqlGroup) modelFile);
	         

//	        if(!modelFile.getId().equals("TlNbXxgl11")){
//	        	JavaClassModel ret6 =	ModelJavaGenerator.generateClassImpl(modelFile,true);
//	        	System.out.println(ret6.getJavaContent());
//	        }
	      }
	    
        NsqlExcelProcessor nsql=     new NsqlExcelProcessor();
        File file=   new File("C:/Users/zte/git/nosqlproject/src/main/resources/nsql2.xls");
        nsql.process(models,file);
	    
	    
	}
	
	
	
}